using UnityEngine;
using System.Collections;

public class DiaryView : MonoBehaviour
{
	public GameObject showedDiaryPage;
	public GameObject showedDiaryPage_small;
	public GameObject btnLeft;
	public GameObject btnRight;
	public GameObject btnInsert;
	public GameObject btnRemove;
	public GameObject btnReturn;
	public DiaryManager diaryManager;
	public PuzzleRoomManager puzzleRoomManager;

	// Use this for initialization
	void Start ()
	{
		btnLeft = GameObject.Find("lef");
		btnRight = GameObject.Find("rig");
		btnInsert = GameObject.Find("insG");
		btnRemove = GameObject.Find("remG");
		btnReturn = GameObject.Find("dow");
		diaryManager = GameObject.Find("DiaryManager").GetComponent<DiaryManager>();
		puzzleRoomManager = GameObject.Find("PuzzleRoomManager").GetComponent<PuzzleRoomManager>();
		showedDiaryPage = GameObject.Find("currentActivePage");
		showedDiaryPage_small = GameObject.Find("currentActivePage_small");
	}
	
		// Update is called once per frame
	void Update ()
	{
		if(Input.GetMouseButtonDown(0))
		{
			if(puzzleRoomManager.puzzleRoomData.Mouse.collider2D.bounds.Intersects(btnLeft.collider2D.bounds))
				diaryManager.turnLeft();
			if(puzzleRoomManager.puzzleRoomData.Mouse.collider2D.bounds.Intersects(btnRight.collider2D.bounds))
				diaryManager.turnRight();
			if(puzzleRoomManager.puzzleRoomData.Mouse.collider2D.bounds.Intersects(btnInsert.collider2D.bounds))
				diaryManager.InsertPage();
			if(puzzleRoomManager.puzzleRoomData.Mouse.collider2D.bounds.Intersects(btnRemove.collider2D.bounds))
				diaryManager.RemovePage();
			if(puzzleRoomManager.puzzleRoomData.Mouse.collider2D.bounds.Intersects(btnReturn.collider2D.bounds))
				diaryManager.ReturnToLevel();
			if(puzzleRoomManager.puzzleRoomData.Mouse.collider2D.bounds.Intersects(showedDiaryPage_small.collider2D.bounds))
				diaryManager.nextDiaryPage();
		}
	}
}

